package com.scm.java.net.system.action;


import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.scm.entity.base.SupDrugIn;
import com.scm.entity.system.SysMenu;
import com.scm.entity.system.SysUsers;
import com.scm.java.net.system.service.MenuManageService;

public class HomeAction extends BasicAction {

    private static final long serialVersionUID = 7071566986229355381L;

    private MenuManageService menuManageService;

    private List<SysMenu> menuList;
    private List<SupDrugIn> drugIns;
    public String execute() throws SQLException {
        if (ActionContext.getContext().getSession().get("loginUser") == null) {
            return "login";
        }
        return "success";
    }

    public String loadMenu() throws Exception {
        SysUsers user = (SysUsers) session.get("loginUser");
        if(user==null){
        	return "login";
        }
        menuList = menuManageService.getMenuTree("root", user.getRoleList());
        return "menuTree";
    }
    public String alarmMessage() throws SQLException{
    	Map paraMap=new HashMap();
    	SupDrugIn drugIn=new SupDrugIn();
    	drugIn.setAmount(0);
    	paraMap.put("drugIn", drugIn);
    	drugIns=dao.queryList("drugin.getDrugins", paraMap);
    	return "welcome";
    }
    public void setMenuManageService(MenuManageService menuManageService) {
        this.menuManageService = menuManageService;
    }

    public List<SysMenu> getMenuList() {
        return menuList;
    }

	public List<SupDrugIn> getDrugIns() {
		return drugIns;
	}

	public void setDrugIns(List<SupDrugIn> drugIns) {
		this.drugIns = drugIns;
	}

}
